package com.runjian.rundo.iot.agent.common.network.tcp.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

import lombok.Data;

/**
 * tcp透传网络组件配置
 *
 * @author CaoQingHua
 */
@Data
@ConfigurationProperties("network.tcp")
public class TcpNetworkProperties {

    /**
     * 拆包方式
     */
    private String payloadParserType;

    /**
     * 拆包方式为分隔符时的参数
     */
    private Delimited delimited;

    /**
     * 拆包方式为基于长度字段时的参数
     */
    private LengthField lengthField;

    /**
     * 拆包方式为固定长度时的参数
     */
    private FixedLength fixedLength;

    @Data
    public static class Delimited {
        private String delimiter;

        private Integer maxSize;
    }

    @Data
    public static class FixedLength {
        private Integer size;
    }

    @Data
    public static class LengthField {
        private Integer maxFrameLength;

        private Integer lengthFieldOffset;

        private Integer lengthFieldLength;

        private Integer lengthAdjustment;

        private Integer initialBytesToStrip;
    }
}
